/****************************************Copyright (c)**************************************************
**                                         2016-03
**
**                                
**
**
**--------------File Info-------------------------------------------------------------------------------
** File name:		    ht6x1x_spi.h
** Last modified Date:  2016-03-29
** Last Version:		v1.0
** Descriptions:		
**
**------------------------------------------------------------------------------------------------------
** Created by:			Evan Chen
** Created date:		2016-03-29
** Version:				v1.0
** Descriptions:		
**
**------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
**
********************************************************************************************************/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HT6X1X_SPI_H
#define __HT6X1X_SPI_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "ht60xx.h"

/*SPICON*/
#define SPICON_SSDIS_MASK       	((uint16_t)0x0080)
#define SPICON_SSDIS_DIS     	((uint16_t)0x0000)
#define SPICON_SSDIS_EN       	((uint16_t)0x0080)

#define SPICON_SPR_MASK       	((uint16_t)0x0070)
#define SPICON_SPR_FSYS_DIV2   	((uint16_t)0x0000)
#define SPICON_SPR_FSYS_DIV4   	((uint16_t)0x0010)
#define SPICON_SPR_FSYS_DIV8   	((uint16_t)0x0020)
#define SPICON_SPR_FSYS_DIV16   ((uint16_t)0x0030)
#define SPICON_SPR_FSYS_DIV32  	 ((uint16_t)0x0040)
#define SPICON_SPR_FSYS_DIV64   ((uint16_t)0x0050)
#define SPICON_SPR_FSYS_DIV128 ((uint16_t)0x0060)
#define SPICON_SPR_NO_CLOCK   	((uint16_t)0x0070)

#define SPICON_CPHA_MASK       	((uint16_t)0x0008)
#define SPICON_CPHA_HALF     	((uint16_t)0x0000)
#define SPICON_CPHA_ONE      	((uint16_t)0x0008)

#define SPICON_CPOL_MASK       	((uint16_t)0x0004)
#define SPICON_CPOL_LOW     	((uint16_t)0x0000)
#define SPICON_CPOL_HIHG       	((uint16_t)0x0004)

#define SPICON_MSTR_MASK       	((uint16_t)0x0002)
#define SPICON_MSTR_SLAVE     	((uint16_t)0x0000)
#define SPICON_MSTR_MASTER     	((uint16_t)0x0002)

#define SPICON_SPI_EN_MASK        ((uint16_t)0x0001)
#define SPICON_SPI_DIS     		((uint16_t)0x0000)
#define SPICON_SPI_EN		       	((uint16_t)0x0001)

/*SPISTA*/
#define SPISTA_SPIF_MASK       	((uint16_t)0x0008)
#define SPISTA_WCOL_MASK       	((uint16_t)0x0004)
#define SPISTA_SSERR_MASK       	((uint16_t)0x0002)
#define SPISTA_MODF_MASK       	((uint16_t)0x0001)

/*SPIDAT*/
#define SPIDAT_MASK       		((uint16_t)0x00FF)

/*SPISSN*/
#define SPISSN_SSN0_MASK       	((uint16_t)0x0001)
#define SPISSN_SSN0_LOW		((uint16_t)0x0000)
#define SPISSN_SSN0_HIGH     	((uint16_t)0x0001)

void SPI_Enable(HT_SPI_TypeDef  *SPIx);
void SPI_Disable(HT_SPI_TypeDef  *SPIx);

#ifdef __cplusplus
}
#endif

#endif /* __HT6X1X_SPI_H */

